package solutions;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import org.pi4.locutil.GeoPosition;
import org.pi4.locutil.MACAddress;
import org.pi4.locutil.trace.TraceEntry;

public class WifiPositionsParser {
	public static List<TraceEntry> parser(String file) throws IOException {
		ArrayList<TraceEntry> entries = new ArrayList<TraceEntry>();

		BufferedReader reader = new BufferedReader(new FileReader(
				new File(file)));
		// Skip first line with info about order
		reader.readLine();
		String s = null;

		while ((s = reader.readLine()) != null) {
			s = s.trim();
			String[] splitting = s.split(" ");
			MACAddress address = MACAddress.parse(splitting[0]);
			GeoPosition position = new GeoPosition(
					Double.parseDouble(splitting[1]),
					Double.parseDouble(splitting[2]));

			entries.add(new TraceEntry(Long.parseLong(splitting[3]), position,
					address, null));
		}
		return entries;
	}
}
